/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mintandleaf.webkits.validator;
/**
 * Validator fo email address we are using apache common validator 1.3
 * as main validation library
 * @author teguhh
 */
public class EmailValidator extends BaseValidator{

    /**
     * construct a basic EmailValidator
     */
    public EmailValidator(){
        setErrorMessage("It's not valid email address");
    }

    /**
     * construct a basic EmailValidator with
     * custom error message
     * @param custom error message
     */
    public EmailValidator(String paramErrorMessage){
        setErrorMessage(paramErrorMessage);
    }

    /**
     * Validate email address
     * @param value the address to be validate
     * @return true on valid email address false on invalid email address
     */
    @Override
    public boolean validate(Object value) {
        org.apache.commons.validator.EmailValidator validator=org.apache.commons.validator.EmailValidator.getInstance();
        return validator.isValid(String.valueOf(value));
    }

}
